using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 默认攻击策略 - 近战攻击，直接造成伤害
/// </summary>
public class DefaultAttack : AttackStrategyBase
{
    public DefaultAttack(SkillData data)
    {
        AttackData = data;
    }

    public override void Execute(Entity target)
    {
        base.Execute(target);

        if (target == null || target.HealthComponent == null)
        {
            Logger.LogWarning("DefaultAttack", $"{Owner?.name} 攻击目标无效");
            return;
        }

        // 如果技能数据有Effects列表，使用SkillExecutor执行效果
        if (AttackData != null && AttackData.Effects != null && AttackData.Effects.Count > 0)
        {
            SkillExecutor.Execute(AttackData.Effects, Owner, target);
            Logger.Log("DefaultAttack", $"{Owner?.name} 通过效果列表攻击 {target.name}");
        }
        else
        {
            // 如果没有效果列表，直接造成伤害
            long damage = AttackData?.Damage ?? 100;
            target.HealthComponent.TakeDamage(damage);
            Logger.Log("DefaultAttack", $"{Owner?.name} 对 {target.name} 造成 {damage} 点伤害,Range :{AttackData.Range}，target.HealthComponent.CurHealth：{target.HealthComponent.CurHealth}");

        }
    }
}
